<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>导航栏云</title>
    <script src="../util.js"></script>
</head>
<style>
    *{margin: 0; padding: 0;}
        ul {list-style:none;}
        body {
            background-color: #000;
        }
        .nav {
            width: 800px;
            height: 42px;
            background:#fff;
            margin: 100px auto;
            border-radius: 5px;
            position: relative; 
        }
        .cloud {
            width: 100px;
            height: 42px;
            position: absolute;
            top: 0;
            left: 0;
            background: url(../cloud.gif) no-repeat;
            background-size: 100px 42px;
        }
        .nav ul {
            position: absolute;
            top: 0;
            left: 0;
        }
        .nav li {
            float: left;
            width: 100px;
            height: 42px;
            line-height: 42px;
            text-align: center;
            color: #000;
            cursor: pointer;
        }
</style>
<body>
    <div class="nav" id="nav">
        <span class="cloud" id="cloud"></span>
        <ul id="box">
            <li>首页新闻</li>
            <li>千锋师资</li>
            <li>千锋活动策划</li>
            <li>企业文化</li>
            <li>招聘信息</li>
            <li>公司简介</li>
            <li>上海校区</li>
            <li>广州校区</li>
        </ul>
    </div>
    <script>
        var div = document.querySelector('div')
        var span = document.querySelector('span')
        var list = document.querySelectorAll('li')
        
        // console.log(span)
        var index = 0
        for(let i=0;i<list.length;i++){
            list[i].onmouseenter = function(){
                utils.move(span,'left',this.offsetLeft,500)
            }
            list[i].onmouseleave = function(){
                utils.move(span,'left',list[index].offsetLeft,500)
            }
            list[i].onclick = function(){
                console.log(1)
                index = i
                utils.move(span,'left',this.offsetLeft,500)
            }
        }
    </script>
</body>
</html>